home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_0799 / 576 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  4.8 KB

  1. From: Kay Roemer <roemer@informatik.uni-frankfurt.de>
  2. Posted-Date: Mon, 25 Oct 93 8:09:40 MEZ
  3. Received-Date: Mon, 25 Oct 93 08:09:40 +0100
  4. Message-Id: <9310250709.AA22263@hera.rbi.informatik.uni-frankfurt.de>
  5. Subject: sleep() ...
  6. To: mint@atari.archive.umich.edu
  7. Date: Mon, 25 Oct 93 8:09:40 MEZ
  8. Mailer: Elm [revision: 70.85]
  9.  
  10. The following patches make sleep() return whether
  11. or not it was interrupted by delivery of signals.
  12. It returns nonzero if it was interrupted by signals.
  13.  
  14. The diffs are relative to 1.09.
  15.  
  16. These changes should make it easy to change pipefs
  17. (to Eric ...) so that it does NOT touch objects
  18. that could have been kfree()'ed by a signal handler
  19. while sleep()ing:
  20.  
  21. Simply change
  22.     sleep(IO_Q, cond);
  23. into
  24.     if (sleep(IO_Q, cond)) {
  25.         /* Handle interrupted system call */
  26.     }
  27. where appropriate.
  28.  
  29. My next message contains diffs to change Fselect()
  30. so that it really works for multiple processes
  31. select()ing the same file. I posted that already
  32. some time ago, but this version makes use of the
  33. new sleep(), thus giving somewhat cleaner code :-).
  34.  
  35. Cheers -- Kay.
  36.  
  37. *** file.h.orig    Fri Oct 22 18:50:52 1993
  38. --- file.h    Fri Oct 22 18:52:08 1993
  39. ***************
  40. *** 232,238 ****
  41.    * to sleep
  42.    */
  43.       void    ARGS_ON_STACK (*nap) P_((unsigned));
  44. !     void    ARGS_ON_STACK (*sleep) P_((int que, long cond));
  45.       void    ARGS_ON_STACK (*wake) P_((int que, long cond));
  46.       void    ARGS_ON_STACK (*wakeselect) P_((long param));
  47.   
  48. --- 232,238 ----
  49.    * to sleep
  50.    */
  51.       void    ARGS_ON_STACK (*nap) P_((unsigned));
  52. !     short    ARGS_ON_STACK (*sleep) P_((int que, long cond));
  53.       void    ARGS_ON_STACK (*wake) P_((int que, long cond));
  54.       void    ARGS_ON_STACK (*wakeselect) P_((long param));
  55.   
  56. *** proc.c.orig    Mon Sep 13 21:22:00 1993
  57. --- proc.c    Fri Oct 22 19:58:24 1993
  58. ***************
  59. *** 107,112 ****
  60. --- 107,113 ----
  61.       p->ppid = curproc->pid;
  62.       p->pid = newpid();
  63.       p->sigpending = 0;
  64. +     p->nsigs = 0;
  65.       p->sysstack = (long)(p->stack + STKSIZE - 12);
  66.       p->ctxt[CURRENT].ssp = p->sysstack;
  67.       p->ctxt[SYSCALL].ssp = (long)(p->stack + ISTKSIZE);
  68. ***************
  69. *** 451,463 ****
  70.       p->slices = SLICES(p->curpri);
  71.   }
  72.   
  73. ! void ARGS_ON_STACK 
  74.   sleep(que, cond)
  75.       int que;
  76.       long cond;
  77.   {
  78.       PROC *p;
  79.       short sr;
  80.       extern short kintr;    /* in bios.c */
  81.   #ifndef MULTITOS
  82.   #ifdef FASTTEXT
  83. --- 452,465 ----
  84.       p->slices = SLICES(p->curpri);
  85.   }
  86.   
  87. ! short ARGS_ON_STACK 
  88.   sleep(que, cond)
  89.       int que;
  90.       long cond;
  91.   {
  92.       PROC *p;
  93.       short sr;
  94. +     ulong onsigs = curproc->nsigs;
  95.       extern short kintr;    /* in bios.c */
  96.   #ifndef MULTITOS
  97.   #ifdef FASTTEXT
  98. ***************
  99. *** 478,484 ****
  100.       if (que == READY_Q && !sys_q[READY_Q]) {
  101.   /* we're just going to wake up again right away! */
  102.           do_wakeup_things();
  103. !         return;
  104.       }
  105.   
  106.       sr = spl7();
  107. --- 480,486 ----
  108.       if (que == READY_Q && !sys_q[READY_Q]) {
  109.   /* we're just going to wake up again right away! */
  110.           do_wakeup_things();
  111. !         return (onsigs != curproc->nsigs);
  112.       }
  113.   
  114.       sr = spl7();
  115. ***************
  116. *** 548,554 ****
  117.               *((void **)0x44eL) = curproc->logbase;
  118.   #endif
  119.           do_wakeup_things();
  120. !         return;
  121.       }
  122.   /*
  123.    * save per-process variables here
  124. --- 550,556 ----
  125.               *((void **)0x44eL) = curproc->logbase;
  126.   #endif
  127.           do_wakeup_things();
  128. !         return (onsigs != curproc->nsigs);
  129.       }
  130.   /*
  131.    * save per-process variables here
  132. ***************
  133. *** 567,572 ****
  134. --- 569,576 ----
  135.       }
  136.       assert(p->magic == CTXT_MAGIC);
  137.       change_context(&(p->ctxt[CURRENT]));
  138. +     /* not reached */
  139. +     return 0;
  140.   }
  141.   
  142.   /*
  143. *** proc.h.orig    Fri Oct 22 18:38:30 1993
  144. --- proc.h    Fri Oct 22 18:39:56 1993
  145. ***************
  146. *** 170,175 ****
  147. --- 170,177 ----
  148.       ushort    sigflags[NSIG];        /* signal flags            */
  149.       ulong    sigextra[NSIG];        /* additional signals to be masked
  150.                          on delivery     */
  151. +     ulong    nsigs;            /* # of delivered signals    */
  152. +     
  153.       char    *mb_ptr;        /* p_msg buffer ptr        */
  154.       long    mb_long1, mb_long2;    /* p_msg storage        */
  155.       long    mb_mbid;        /* p_msg id being waited for    */
  156. *** proto.h.orig    Fri Oct 22 18:50:02 1993
  157. --- proto.h    Fri Oct 22 18:50:36 1993
  158. ***************
  159. *** 246,252 ****
  160.   void add_q P_((int que, PROC *proc));
  161.   void rm_q P_((int que, PROC *proc));
  162.   void ARGS_ON_STACK preempt P_((void));
  163. ! void ARGS_ON_STACK sleep P_((int que, long cond));
  164.   void ARGS_ON_STACK wake P_((int que, long cond));
  165.   void ARGS_ON_STACK wakeselect P_((long param));
  166.   void DUMPPROC P_((void));
  167. --- 246,252 ----
  168.   void add_q P_((int que, PROC *proc));
  169.   void rm_q P_((int que, PROC *proc));
  170.   void ARGS_ON_STACK preempt P_((void));
  171. ! short ARGS_ON_STACK sleep P_((int que, long cond));
  172.   void ARGS_ON_STACK wake P_((int que, long cond));
  173.   void ARGS_ON_STACK wakeselect P_((long param));
  174.   void DUMPPROC P_((void));
  175. *** signal.c.orig    Fri Sep 17 15:32:58 1993
  176. --- signal.c    Fri Oct 22 20:50:50 1993
  177. ***************
  178. *** 265,270 ****
  179. --- 263,269 ----
  180.   
  181.       extern void sig_return();
  182.   
  183. +     ++curproc->nsigs;
  184.       if (curproc->sighandle[sig] == SIG_IGN)
  185.           return;
  186.       else if (curproc->sighandle[sig] == SIG_DFL) {
  187.  
  188.